﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
namespace com.kmxy.Common
{
    /// <summary>
    /// 使用log4net记录日志信息
    /// </summary>
    public class LogHelper
    {
        public static void Write(Type t, Exception e, string header, LogType type = LogType.Debug)
        {
            log4net.ILog loger = log4net.LogManager.GetLogger(t);
            switch (type)
            {
                case LogType.Debug:
                    loger.Debug($"{header}-Debug", e);
                    break;
                case LogType.Error:
                    loger.Error($"{header}-Error", e);
                    break;
                case LogType.Info:
                    loger.Info($"{header}-Info", e);
                    break;
            }
        }

        public static void Write(Type t, string message, string header, LogType type = LogType.Debug)
        {

            log4net.ILog loger = log4net.LogManager.GetLogger(t);
            switch (type)
            {
                case LogType.Debug:
                    loger.Debug($"{header}-Debug\t Mseeage:{message}");
                    break;
                case LogType.Error:
                    loger.Error($"{header}-Error\t Mseeage:{message}");
                    break;
                case LogType.Info:
                    loger.Info($"{header}-Error\t Mseeage:{message}");
                    break;
            }


        }


    }

    public enum LogType
    {
        Info,
        Error,
        Debug,
    }
}